package com.ruoyi.common.context;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


/**
 * 获取userId上下文环境
 *
 * @author yangyouwang
 */
public class ApiUserContext {

    /**
     * 用于保存线程相关信息
     */
    static ThreadLocal<UserContext> threadLocal = new ThreadLocal<>();


    public static UserContext getLocalUser() {
        return threadLocal.get();
    }


    public static void setLocalUser(UserContext userContext) {
        threadLocal.set(userContext);
    }


    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class UserContext {
        private String userId;
    }


}